<include file="public@header" />
<style type="text/css">
	.well{
		text-align: right;
		padding-right: 10px;
	}
	.sql_text{
		height: 95%;
	}
</style>
</head>
<body>
	<div class="wrap js-check-wrap">
		<h1>{$table_name}</h1>
        <form class="well form-inline margin-top-20" method="post" action="{:url('User/index')}">
            <a class="btn btn-success" href="#">添加信息</a>
        </form>
		<table class="table table-hover table-bordered">
			<thead>
				</tr>
					<foreach name="table_head" item="vo">
						<th>{$vo}</th>
					</foreach>
					<td>操作</td>
				<tr>

			</thead>
			<tbody>
				<foreach name="data.list.data" item="item">
				<tr>
					<foreach name="colomn" item="col">
						<switch name="col">
						    <case value="create_time">
						    	<td>{$item[$col]|date="Y-m-d H:i:s",###}</td>
						    </case>
						    <case value="update_time">
					    		<td>{$item[$col]|date="Y-m-d H:i:s",###}</td>
					    	</case>
						    <case value="status">
						    	<switch name="$item[$col]">
						    		<case value="1">
								    	<td><span class="text-success">正常</span></td>
								    </case>
								    <case value="2">
								    	<td><span class="text-danger">删除</span></td>
								    </case>
								    <case value="3">
								    	<td><span class="text-warning">异常</span></td>
								    </case>
								    <default />{$item[$col]}
						    	</switch>
						    </case>
						    <default /><td>{$item[$col]}</td>
						</switch>
					</foreach>
					<td>
						<a href="{:url('GPSDetail/detail', ['category_id' => $category_id, 'detail_id' => $item.id])}" class="open_detail" >{:lang('EDIT')}</a>
					</td>
				</tr>
				</foreach>
			</tbody>
		</table>
		<div class="pagination">{$data.page}</div>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
	<script type="text/javascript">
		$(function(){
			$(".add_category").bind("click", function(){
				layer.prompt({title: '请输入分类名称', formType: 0}, function(category_name, index){
			  		$.ajax({
			  			url: '{:url('GPSCategory/add')}',
			  			type: "POST",
			  			dataType: 'json',
			  			data: {'category_name': category_name},
			  			success: function(res){
			  				if(res.code > 0){
			  					window.location.href = res.url;
			  				}else{
			  					layer.alert(res.msg, {
								  icon: 2,
								});
			  				}

		  					layer.close(index);
			  			}
			  		})
				});
			})

			$(document).on('click', '.open_detail', function(){
				var title = "编辑信息";
				var href = $(this).attr('href');

				layer.open({
				    type: 2,
				    title: title,
				    shadeClose: true,
				    shade: 0.8,
				    area: ['80%', '90%'],
				    content:  href
				}); 
				return false;
			})
		})
	</script>
</body>
</html>